package com.example.demo.batis;

import com.example.demo.control.UserBean;
import com.example.demo.control.UserBean2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user2")
public class UserControl {

    @Autowired
    private UserMapper userDao;

    @RequestMapping("/user1")
    public List<UserBean> test1() {
        return userDao.findAll();
    }

    @RequestMapping("/user3")
    public List<UserBean2> test3() {
        return userDao.findAll2();
    }

    @RequestMapping("/user4")
    public List<UserBean> test4(String name, String pd) {
        UserBean userBean = new UserBean();
        userBean.setName(name);
        userBean.setPd(pd);
        return userDao.findAll3(userBean);
    }
    @RequestMapping("/user5")
    public List<UserBean> test5(String name) {
        UserBean userBean = new UserBean();
        userBean.setName(name);
        return userDao.findAll4(userBean);
    }
    @RequestMapping("/user6")
    public List<UserBean> test6(String name) {
        return userDao.findAll5(name);
    }

    @RequestMapping("/user2")
    public int test2() {
        UserBean userBean = new UserBean();
        userBean.setName("22");
        userBean.setPd("44");
        int i = userDao.insertUser(userBean);
        return userBean.getId();
    }
}
